package com.example.vp.controller.user;

import com.common.domain.R;
import com.common.holder.UserHolder;
import com.example.vp.domian.enetity.Type;
import com.example.vp.service.SubscribeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

@RequestMapping("/subscribe/user")
@RestController("subscribe-user")
public class SubscribeController {
    @Autowired
    private SubscribeService subscribeService;
    @PostMapping
    public R subscribe(@RequestParam Set<Long> typeId){
        System.out.println("typeId"+typeId);
        subscribeService.subscribe(typeId);
        return R.ok().data("订阅成功咯~");
    }
    
    /**
     * 获取用户订阅的分类
     * @return
     */
    @GetMapping("/subscribe")
    public R getUserSubscribe(){
        Long userId = UserHolder.getUserId();
        List<Type> types = subscribeService.getSubscribe(userId);
        return R.ok().data(types);
    }
}
